class Solution:
    def numWays(self, steps: int, arrLen: int) -> int:
        mod = 1e9+7
        maxn=min(arrLen-1,steps)

        dp=[[0] * (maxn + 1) for _ in range(steps + 1)]
        dp[0][0]=1

        for i in range(1,steps+1):
            for j in range(0,maxn+1):
                dp[i][j]=dp[i-1][j]
                if j-1>=0:
                    dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod
                if j+1<=maxn:
                    dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod

        return int(dp[steps][0])